# !/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
===========================
@Time : 2022/7/13 0013 0:52
@Author : 测试开发工程师
@File : pymyaql实现数据断言.py
@Software: PyCharm
============================
"""
import pymysql

"""
有些公司要求。除了校验接口返回来的数据外。还需校验数据库
"""


def query_db():
    coon = pymysql.Connect(host="47.92.149.0", port=3366, database="test_db", user="root", password="123456",
                           charset="utf8")
    cursor = coon.cursor()
    sql = "some sql"
    cursor.execute(sql)
    print("行数", cursor.rowcount)
    # 获取行数
    datas = cursor.fetchall()
    print("查询到的数据为：", datas)  # 获取多条数据
    cursor.close()
    coon.close()
    return datas
